#include <stdlib.h>
#include <stdio.h>

#include <SDL/SDL_mixer.h>
#include <SDL/SDL.h>

void music()
{
    int done=0;
    SDL_Event event;

    SDL_WM_SetCaption("jeu de nim", NULL);
    if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 1024) == -1)
    {
        printf("%s", Mix_GetError());
    }
    Mix_Music *musique;
    musique = Mix_LoadMUS("data/boyard.mp3");
    Mix_PlayMusic(musique, -1);

    while(done)
    {
        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
            case SDL_QUIT:
                done = 0;
                break;
            case SDL_KEYDOWN:
            {

                if (event.key.keysym.sym == SDLK_ESCAPE)
                {
                    done = 0;



                    Mix_FreeMusic(musique); //Libération de la musique
                    Mix_CloseAudio();
                }
            }

            }
        }
    }
}
